package com.zxp.common.core.security.authorize.impl;

import com.zxp.common.core.security.authorize.MyAuthorizationConfigurerService;
import com.zxp.common.core.security.authorize.ZxpAuthorizationConfigurerManager;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;

import java.util.List;
import java.util.Set;

/**
 * @author shollin
 * @desc
 * @date 2021/7/18/018 22:51
 */
@RequiredArgsConstructor
@Slf4j
public class ZxpAuthorizationConfigurerManagerImpl implements ZxpAuthorizationConfigurerManager {

    private final List<MyAuthorizationConfigurerService> authorizationConfigurerServices;

    @Override
    public void config(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
        for (MyAuthorizationConfigurerService authorizationConfigurerService:
             authorizationConfigurerServices ) {
            authorizationConfigurerService.config(config);
        }
        config.anyRequest().authenticated();
    }
}
